package org.rcy.framework.rpc.registry.thrift;

import org.apache.thrift.ProcessFunction;
import org.rcy.framework.thrift.metadata.MethodMetaData;
import org.rcy.framework.thrift.struct.ArgsStruct;

public abstract class MethodHandler<I> extends ProcessFunction<I, ArgsStruct> {

	private MethodMetaData methodMetaData;
	
	private String serviceName;
	
	public MethodHandler(MethodMetaData methodMetaData) {
		super(methodMetaData.getMethodName());
		this.methodMetaData = methodMetaData;
	}
	
	public MethodHandler(MethodMetaData methodMetaData,String serviceName ) {
		super(methodMetaData.getMethodName());
		this.methodMetaData = methodMetaData;
		this.serviceName = serviceName;
	}


	@Override
	protected boolean isOneway() {
		return false;
	}

	@Override
	public ArgsStruct getEmptyArgsInstance() {
		return new ArgsStruct(methodMetaData);
	}

	public String getServiceName() {
		return serviceName;
	}
}